<html>
	<head>
		<title>Product management</title>
	</head>
	<body>
		<table>
			<thead><tr><th>Product Name</th><th>Latest Version</th><th>Alpha Version</th><th>Beta Release</th><th>Final Release</th><th>Log Files</th></tr></thead>
			<tbody>
<?php
	if(isset($_REQUEST['to']))
	{
		copy( "../products/".$_REQUEST['product']."/".$_REQUEST['from'].".txt", "../products/".$_REQUEST['product']."/".$_REQUEST['to'].".txt" );
	}
	if(isset($_REQUEST['op']))
	{
		$op = $_REQUEST['op'];
		if($op=="delete")
			unlink( "../products/".$_REQUEST['product']."/".$_REQUEST['from'].".txt" );
	}
	$handle = opendir('../products');
	while (false !== ($entry = readdir($handle))) {
		if ($entry != "." && $entry != ".." && is_dir('../products/'.$entry)) {
			echo '<tr>';
			echo '<td>'.str_replace('_',' ',$entry).'</td>';
			echo '<td>'.@file_get_contents('../products/'.$entry.'/last.txt').'<a href="products.php?product='.$entry.'&to=alpha&from=last"><img src="up.png" alt="Upgrade to alpha"></a></td>';
			$alpha = @file_get_contents('../products/'.$entry.'/alpha.txt');
			echo '<td>'.$alpha;
			if(!empty($alpha))
				echo '<a href="products.php?product='.$entry.'&to=beta&from=alpha"><img src="up.png" alt="Upgrade to beta"></a>'.
						'<a href="products.php?product='.$entry.'&op=delete&from=alpha"><img src="delete.png" alt="Remove"></a>';
			$beta = @file_get_contents('../products/'.$entry.'/beta.txt');
			echo '</td><td>'.$beta;
			if(!empty($beta))
				echo '<a href="products.php?product='.$entry.'&to=final&from=beta"><img src="up.png" alt="Upgrade to final"></a>'.
					'<a href="products.php?product='.$entry.'&op=delete&from=beta"><img src="delete.png" alt="Remove"></a>';
			$final = @file_get_contents('../products/'.$entry.'/final.txt');
			echo '</td><td>'.$final;
			if(!empty($final))
				echo '<a href="products.php?product='.$entry.'&op=delete&from=final"><img src="delete.png" alt="Remove"></a>';
			echo '<td>[notsent][sent]</td>';
			echo '</td></tr>';
		}
    }
	closedir($handle);
?>
			</tbody>
		</table>
	</body>
</html>

<?php

?>
